package com.rem.chat.controller;

import com.rem.chat.aop.annotation.GlobalInterceptor;
import com.rem.chat.common.utils.JacksonUtil;
import com.rem.chat.pojo.request.BeautyIdAddRequest;
import com.rem.chat.pojo.request.BeautyIdModifyRequest;
import com.rem.chat.pojo.request.PageRequest;
import com.rem.chat.pojo.response.CommonResult;
import com.rem.chat.pojo.response.LoadAllBeautyIdResponse;
import com.rem.chat.service.BeautyService;
import jakarta.annotation.Nullable;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author: Themberfue
 * @date: 2025/6/9 19:23
 * @description:
 */
@RestController
@RequestMapping("/admin/beauty")
public class BeautyController {
    private static final Logger log = LoggerFactory.getLogger(BeautyController.class);

    @Resource(name = "beautyServiceImpl")
    BeautyService beautyService;

    @GetMapping("/loadBeautyIdList")
    @GlobalInterceptor(checkAdmin = true)
    public CommonResult<LoadAllBeautyIdResponse> loadBeautyIdList(@RequestBody @Nullable @Validated PageRequest param) {
        log.info("loadAllUser PageRequest:{}", JacksonUtil.writeValueAsString(param));

        return CommonResult.success(beautyService.loadBeautyIdList(param));
    }

    @PostMapping("/addBeautyId")
    @GlobalInterceptor(checkAdmin = true)
    public CommonResult<Boolean> addBeautyId(@RequestBody @Validated BeautyIdAddRequest request) {
        log.info("addBeautyId BeautyIdAddRequest:{}", JacksonUtil.writeValueAsString(request));

        return CommonResult.success(
                beautyService.addBeautyId(request));
    }

    @PutMapping("/modifyBeautyId")
    @GlobalInterceptor(checkAdmin = true)
    public CommonResult<Boolean> modifyBeautyId(@RequestBody @Validated BeautyIdModifyRequest request) {
        log.info("modifyBeautyId BeautyIdModifyRequest:{}", JacksonUtil.writeValueAsString(request));

        return CommonResult.success(
                beautyService.modifyBeautyId(request));
    }

    @DeleteMapping("/delBeautyId")
    @GlobalInterceptor(checkAdmin = true)
    public CommonResult<Boolean> delBeautyId(@NotNull Integer id) {
        log.info("delBeautyId id:{}", JacksonUtil.writeValueAsString(id));

        return CommonResult.success(
                beautyService.delBeautyId(id));
    }
}
